from ddparser import DDParser
from LAC import LAC
ddp = DDParser()
def COO_binglie(ddp,l):
    s = ddp.parse(l)
    d = s[0]
    print(d)
    deprel_l = d['deprel']
    word_l = d['word']
    head_l = d['head']
    for idx,i in enumerate(deprel_l):
        if i =='COO':
            print(word_l[idx]+':COO')
            head_idx = head_l[idx]-1
            print(word_l[head_idx],deprel_l[head_idx])

if __name__ == '__main__':
    lac = LAC(mode='lac')
    ddp = DDParser()
    with open('./data/input.txt','r',encoding='utf-8') as f:
        text = f.read().replace('\n','').replace('　','')
    # l = text.split('，')     #按小句分,存在一个逻辑问题，按小句分时，实际上是遇到，和。都分。
    l = text.split('。')     #按大句分
    for i in l:
        if i == '':
            continue
        words = COO_binglie(ddp,i)
